<a class="btn btn-danger" data-role="addTo"><i class="icon-plus"></i> 添加到常用操作</a>
{php}$controller = request()->controller();
     $action = request()->action();
    $current = db('Menu')->where("url like '%$controller/" . $action . "' AND pid > 0")->field('id')->find();
{/php}


<script>
    $('[data-role="addTo"]').click(function () {
        var id = "{$current['id']}";
        var url = "{:url('Admin/Index/addTo')}";
        $.post(url, {id: id}, function (msg) {
            if (msg.status) {
                console.log(msg);
                toast.success(msg.info);
                /*setTimeout(function () {
                 window.location.reload();
                 }, 500);*/
            } else {
                toast.error(msg.info);
            }
        }, 'json')
    });
</script>
